/**
 * @Author: wangliuyang
 * @Date: 2021/8/16 11:44
 * @Description:125. 验证回文串
 */
public class Solution_125 {
    public boolean isPalindrome(String s) {
        int left = 0;
        int right = s.length() - 1;
        while (left < right){
            char l = s.charAt(left);
            char r = s.charAt(right);
            if (!Character.isLetterOrDigit(l)){
                left++;
                continue;
            }
            if (!Character.isLetterOrDigit(r)){
                right--;
                continue;
            }
            if (Character.toUpperCase(l) == Character.toUpperCase(r)){
                left++;
                right--;
            }else {
                return false;
            }
        }
        return true;
    }
}
